#项目设置
set(EXECUTABLE_OUTPUT_PATH ../bin)
set(CMAKE_BUILD_TYPE "Debug")
#项目配置
if(WIN32)
    cmake_minimum_required(VERSION 3.2.0)
    set(CMAKE_C_COMPILER gcc.exe)
    set(CMAKE_CXX_COMPILER g++.exe) 
    set(CMAKE_CXX_STANDARD    17)
    set(CMAKE_CXX_STANDARD_REQUIRED   ON)

    project(learnboost LANGUAGES CXX)

    #设置搜索路径
    set(BOOST_ROOT "C:/Program Files/boost")
    set(Boost_NO_SYSTEM_PAT S ON) 
    find_package (Boost COMPONENTS system thread date_time regex serialization  REQUIRED)

    if(Boost_FOUND)
        include_directories(${Boost_INCLUDE_DIRS})
        
        MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.")
        MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.")
        MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.")
        
        add_executable(main main.cpp) 
    endif()   

    target_link_libraries (main ${Boost_LIBRARIES} ws2_32.lib )
endif()

if(LINUX)
    cmake_minimum_required(VERSION 3.28.3)
    
    set(CMAKE_CXX_STANDARD    17)
    set(CMAKE_CXX_STANDARD_REQUIRED   ON)
    
    project(learnboost LANGUAGES CXX)
    #设置搜索路径
    set(BOOST_ROOT "/usr")
    set(BOOST_LIBRARYDIR "/usr/include/boost/libs")
    set(Boost_NO_SYSTEM_PATHS ON) 
    
    find_package (Boost COMPONENTS  system thread date_time regex serialization json REQUIRED)
    if(Boost_FOUND)
        include_directories(${Boost_INCLUDE_DIRS})
        MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.")
        MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.")
        MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.")
        add_executable(boost_regex boost_regex.cpp)
        add_executable(boost_core boost_core.cpp)
        add_executable(boost_asio boost_asio.cpp)
        add_executable(tcp_server tcp_server.cpp)
        add_executable(tcp_client tcp_client.cpp)
    endif()

    # 添加OpenSSL库
    find_package(OpenSSL REQUIRED)
    include_directories(${OPENSSL_INCLUDE_DIR})
    target_link_libraries(boost_regex ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES})
    target_link_libraries(boost_core  ${Boost_LIBRARIES} )
    target_link_libraries(boost_asio)
    target_link_libraries(tcp_server)
    target_link_libraries(tcp_client)
endif()



